<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
        <button @click="obj.age++">修改age</button>
        <button @click="deleteName">删除name</button>
        <button @click="addSex">新增sex</button>
        <p>{{obj.name}}</p>
        <p>{{obj.sex}}</p>
        <p>{{obj.age}}</p>
    </div>
    <script>
        const vm = new Vue({
            el: '#app',
            data() {
                return {
                    obj:{
                        name:'laowang',
                        age:25
                    }
                }
            },
            methods:{
                deleteName(){
                    // vm.$delete方法和Vue.delete方法是两种存放在不同位置的同一种方法

                    this.$delete(this.obj,'name')
                    // Vue.delete(this.obj,'name')
                },
                addSex(){
                    this.$set(this.obj,'sex','男')
                    // Vue.set(this.obj,'sex','女')
                    
                },
            }
        })
    </script>
</body>

</html>